package ui;

import engine.Vector2D;
import java.awt.Color;
import java.awt.Graphics;
import ui.DrawingScreen.Bounds;

public class GraphicLine extends GraphicObject {
    //Le point p1 sera la position de l'objet (super.position)
    private Vector2D p2;
    
    public static Double speedUnitToPixelRatio = 100.;
    
    public GraphicLine(Vector2D p1, Vector2D p2, Vector2D speed, Color color) {
        super(p1, speed, color);

        this.p2 = p2;
    }

    @Override
    public void draw(Graphics g) {
        g.setColor(super.color);
        g.drawLine(super.position.getX().intValue(), super.position.getY().intValue(), p2.getX().intValue(), p2.getY().intValue());
    }
    
    @Override
    public boolean isInsideBounds(Bounds bounds){
        return true;
    }
    
    @Override
    public boolean isInsideBoundsNextStep(Bounds bounds, Vector2D maxMove){
        return true;
    }

    public void setP2(Vector2D p2) {
        this.p2 = p2;
    }
    
    //retourne le vecteur formé par l'objet
    public Vector2D calcVector2D(){
        return Vector2D.sub(p2, super.position);
    }
}
